gdkvulkan: Track if we reffed the display's vulkan data
authorBenjamin Otte <otte@redhat.com>
Wed, 4 Jan 2017 17:26:14 +0000 (18:26 +0100)
committerBenjamin Otte <otte@redhat.com>
Wed, 4 Jan 2017 17:26:14 +0000 (18:26 +0100)
When reffing the display fails in init, we were still trying to unref
it. Which obviously failed and spewed warnings to stderr.

gdk/gdkvulkancontext.c

index a6b17326194eaabdda22be33d7bc0a4c0df81057..dae6a345a9fa13c357d6034c5f01007a6f9ecf1d 100644 (file)
@@ -45,6 +45,8 @@ struct _GdkVulkanContextPrivate {
 #endif
 
   guint32 draw_index;
+
+  guint vulkan_ref: 1;
 };
 
 enum {
@@ -166,7 +168,7 @@ gdk_vulkan_context_dispose (GObject *gobject)
 
   /* display will be unset in gdk_draw_context_dispose() */
   display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
-  if (display)
+  if (display && priv->vulkan_ref)
     gdk_display_unref_vulkan (display);
 
   G_OBJECT_CLASS (gdk_vulkan_context_parent_class)->dispose (gobject);
@@ -411,7 +413,8 @@ gdk_vulkan_context_real_init (GInitable     *initable,
   VkBool32 supported;
   uint32_t i;
 
-  if (!gdk_display_ref_vulkan (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), error))
+  priv->vulkan_ref = gdk_display_ref_vulkan (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), error);
+  if (!priv->vulkan_ref)
     return FALSE;
 
   res = GDK_VULKAN_CONTEXT_GET_CLASS (context)->create_surface (context, &priv->surface);